package cn.source.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import cn.source.common.annotation.Log;
import cn.source.common.core.controller.BaseController;
import cn.source.common.core.domain.AjaxResult;
import cn.source.common.enums.BusinessType;
import cn.source.system.domain.GradeLine;
import cn.source.system.service.IGradeLineService;
import cn.source.common.utils.poi.ExcelUtil;
import cn.source.common.core.page.TableDataInfo;

/**
 * 年度分数线Controller
 * 
 * @author sourcebyte.vip
 * @date 2024-03-18
 */
@RestController
@RequestMapping("/system/gradeLine")
public class GradeLineController extends BaseController
{
    @Autowired
    private IGradeLineService gradeLineService;

    /**
     * 查询年度分数线列表
     */
    @PreAuthorize("@ss.hasPermi('system:gradeLine:list')")
    @GetMapping("/list")
    public TableDataInfo list(GradeLine gradeLine)
    {
        startPage();
        List<GradeLine> list = gradeLineService.selectGradeLineList(gradeLine);
        return getDataTable(list);
    }

    /**
     * 导出年度分数线列表
     */
    @PreAuthorize("@ss.hasPermi('system:gradeLine:export')")
    @Log(title = "年度分数线", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, GradeLine gradeLine)
    {
        List<GradeLine> list = gradeLineService.selectGradeLineList(gradeLine);
        ExcelUtil<GradeLine> util = new ExcelUtil<GradeLine>(GradeLine.class);
        util.exportExcel(response, list, "年度分数线数据");
    }

    /**
     * 获取年度分数线详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:gradeLine:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(gradeLineService.selectGradeLineById(id));
    }

    /**
     * 新增年度分数线
     */
    @PreAuthorize("@ss.hasPermi('system:gradeLine:add')")
    @Log(title = "年度分数线", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody GradeLine gradeLine)
    {
        return toAjax(gradeLineService.insertGradeLine(gradeLine));
    }

    /**
     * 修改年度分数线
     */
    @PreAuthorize("@ss.hasPermi('system:gradeLine:edit')")
    @Log(title = "年度分数线", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody GradeLine gradeLine)
    {
        return toAjax(gradeLineService.updateGradeLine(gradeLine));
    }

    /**
     * 删除年度分数线
     */
    @PreAuthorize("@ss.hasPermi('system:gradeLine:remove')")
    @Log(title = "年度分数线", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(gradeLineService.deleteGradeLineByIds(ids));
    }
}
